<?php

declare(strict_types=1);

namespace app\model;

use app\common\validate\AdminRoleValidate;
use app\common\validate\AdminValidate;
use app\model\base\BaseAdminRoleModel;
use think\model\relation\HasManyThrough;

/**
 * 
 *
 * @mixin \think\Model
 * @property int $id
 * @property string $role_name 角色名称
 * @property string $created_at
 * @property string $updated_at
 * @property string $deleted_at 删除时间
 * @property int $is_deleted 是否软删除
 * @property-read \app\model\AdminPermission[] $permissions
 */
class AdminRole extends BaseAdminRoleModel
{
    public $validate = AdminRoleValidate::class; //验证类


    public function permissions(): HasManyThrough
    {
        return $this->hasManyThrough(AdminPermission::class, AdminRolePermission::class, 'role_id', 'id', 'id', 'permission_id');
    }
}
